Building a Relationship Structure

It is possible to define a Relationship from the context item that can go either up or down the data structure.  ‘Down’ refers to a relationship direction starting from the Item representing the source side of the relationship and following the related content to the related Item.  ‘Up’ by contrast refers to a relationship direction starting from the Item representing the related side of the relationship and following the related content to the source Item.  It is also possible to set up a recursive structure, such as the Part --> Part BOM --> Part, to reuse the same logic for multiple levels.  The following procedures show how to expand the query both up and down for a Part Query and introduces recursion.

Building a Downward Relationship Structure

  1. Right-click on the Part Context Item and select Add Related Item --> Using Relationship.

Figure 8.

  1. Select the Relationship to include in the structure.  In this case, select BOM, check Include Related and click Add.

Figure 9.

The query now looks like the following.  Note that the alias ‘Part_1’ is assigned to the related Part Query Element in the list.

Figure 10.

  1. Right-click on the Part Context Item and select Add Related Item --> Using Relationship.  In this case, Press CTRL+click to select Documents and CAD Documents. Check Include Related.

Figure 11.

  1. Right-click on the top Context Item and select Add Related Item --> Using Item Property. Select an Item Property to add to the query structure.  In this case, select created_by_id.

Figure 12.

  1. Use the following procedure to specify the desired Properties for each new element in the Query Definition:

  2. Note: Optionally, you can also set Order By settings as well.

  1. For [created_by_id] User, specify the following properties:

    • Item ID

    • First Name

    • Last Name

    • Login Name

  2. For [Relationship] Part CAD, specify the following property:

    • Sequence

  3. For [Related] CAD, specify the following properties:

    • id

    • Document Number

    • Name

    • State

  4. For [Relationship] Part Document, specify the following property:

    • Sequence

  5. For [Related] Document, specify the following properties:

    • id

    • Document Number

    • Name

    • State

  1. Change the Alias on the CAD Documents element to “Part CAD”:

    1. Right-click on CAD Documents and select Change Alias.

    2. Figure 13.

    3. Enter Part CAD as the name and click the check mark.

    4. Figure 14.

  2. Use the same procedure to change Documents Relationship to Part Document.

  3. Use the same procedure to change User Relationship to Part Created By.

  4. Note: Each element on a given level must have a unique alias.

  1. Save the Query Definition.

Building an Upward Relationship Structure

  1. Right-click on the top Part element and select Add Related Item --> Using Referencing Item.

Figure 15.

  1. Select an appropriate Referencing item from the structure.  In this case, select Simple MCO Part.

Figure 16.

  1. Right-click on the Simple MCO Part element and select Add Related Item --> Using Item Property to select source_id.

Figure 17.

  1. Set Selected Properties on the Simple MCO element to:

  • id

  • MCO Number

  • Status

  • Date Originated

  1. Save the Query Definition.

Adding a Recursive Call Structure

Recursive structures can reuse sections of the already defined queries.  The following example shows how to set up a recursive call for the Part --> Part BOM --> Part relationship structure.

  1. Right-click on the top-level Part element and add the Part BOM --> Part structure as shown.

Figure 18.

  1. For the BOM element, select the following properties:

  • Sequence

  • Quantity

  • related_id

  1. Right-click on the child Part element and select Reuse Query Element Definition.

Figure 19.

  1. Select the top-level Part element and click Add.

Figure 20.

  1. Save the Query Definition item.